<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue学习</title>
    <script src="./js/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 
        此查看按钮他是有权限的，只有地址栏中?name=admin的用户才能查看
       -->
      <button v-permission>查看工资</button>
    </div>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            title: '我是一个标题!',
            show: true
          }
        }
      })

      // 自定义指令
      app.directive('permission', {
        mounted(el) {
          // 权限判断
          if (window.location.search != '?name=admin') {
            el.remove()
          }
        }
      })

      app.mount('#app')
    </script>
  </body>
</html>
